package com.qubuyer.business.home.adapter

import com.qubuyer.R
import com.qubuyer.business.good.activity.GoodDetailActivity
import com.qubuyer.databinding.HomeItemGoodInfoBinding
import com.qubuyer.repository.entitys.HomeGoodEntity
import com.qubuyer.utils.NavigationUtil
import com.qubyer.widget.adapter.HeaderBindingRvAdapter

/**
 * @author Susong
 * @date 创建时间2019/3/9
 * @description 首页Adapter
 */
class HomeAdapter : HeaderBindingRvAdapter<HomeGoodEntity, HomeItemGoodInfoBinding>() {

    override val itemLayout: Int
        get() = R.layout.home_item_good_info

    override fun onRealBind(data: HomeGoodEntity, dataBinding: HomeItemGoodInfoBinding) {
        dataBinding.data = data
        dataBinding.llNowBuy.setOnClickListener {
            if (data.store_count > 0) {
                NavigationUtil.overlay(mContext, GoodDetailActivity::class.java, data.goods_id)
            }
        }
        dataBinding.root.setOnClickListener { NavigationUtil.overlay(mContext, GoodDetailActivity::class.java, data.goods_id) }
        dataBinding.executePendingBindings()
    }
}